<template>
  <div>
    <el-form label-width="100px">
      <el-row type="flex" justify="evenly">
        <el-form-item label="车牌号码:">
          <el-input v-model="carNumber" placeholder="请输入车牌号码" />
        </el-form-item>

        <el-form-item label="缴纳状态">
          <el-select placeholder="未选择">
            <el-option label="全部" :value="1" />
            <el-option label="待缴纳" :value="2" />
            <el-option label="已缴纳" :value="3" />
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSearch">查询</el-button>
        </el-form-item>
      </el-row>
    </el-form>

    <el-table
      v-loading="loading"
      :data="data"
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        type="index"
        width="180"
      >
        <template #default="{$index}">
          {{ $index + 1 + 10 *(page -1) }}
        </template>
      </el-table-column>
      <el-table-column
        prop="carNumber"
        label="车牌号码"
        width="180"
      />
      <el-table-column
        prop="chargeType"
        label="收费类型"
      />
      <el-table-column
        prop="parkingTime"
        label="停车总时长"
      />
      <el-table-column
        prop="actualCharge"
        label="缴纳费用(元)"
      />
      <el-table-column
        prop="paymentStatus"
        label="缴纳状态"
      />
      <el-table-column
        prop="paymentMethod"
        label="缴纳方式"
      />
      <el-table-column
        prop="paymentTime"
        label="缴纳时间"
      />
    </el-table>
    <div class="block" style="float:right">
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20,50,100]"
        :page-size="10"
        layout="total,prev,pager,next,sizes,jumper"
        :total="total"
        @size-change="onSizeChange"
        @current-change="onCurrentChange"
      />

    </div>
  </div>
</template>

<script>
import { getParkingFee } from '@/api/parkingfee'
export default {
  data() {
    return {
      data: [],
      page: 1,
      pageSize: 10,
      total: 0,
      loading: false,
      carNumber: ''
    }
  },
  created() {
    this.onLoad()
  },
  methods: {
    onSearch() {
      this.onLoad()
    },
    async onLoad() {
      this.loading = true
      const { data } = await getParkingFee({ page: this.page, pageSize: this.pageSize })
      this.loading = false
      this.data = data.rows
      this.total = data.total
    },
    onCurrentChange(page) {
      this.page = page
      this.onLoad()
    },
    onSizeChange(page) {
      this.pageSize = page
      this.onLoad()
      this.page = 1
    }
  }
}
</script>

<style>

</style>
